package com.dingding.core.tailwind.dao.impl;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.daox.ICriteriaBaseDao;
import com.dingding.common.core.base.daox.ISQLBaseDao;
import com.dingding.common.core.beans.UserLogin;
import com.dingding.core.tailwind.dao.IDepositPasswordDao;
import com.dingding.core.tailwind.sql.DepositPasswordSQL;

/**
 * 
 * @ClassName: DepositPasswordDaoImpl 
 * @Description: 提现密码DAO实现类
 * @author YHQ
 * @date 2016年12月22日 上午10:24:31
 * @since V2.6.3
 * 
 */
@Component("depositPasswordDao")
public class DepositPasswordDaoImpl implements IDepositPasswordDao{

	private Logger log = Logger.getLogger(this.getClass());
	
	@Resource(name = "SQLBaseDao")
	private ISQLBaseDao sqlBaseDao;

	@Resource(name = "criteriaBaseDao")
	private ICriteriaBaseDao criteriaBaseDao;
	
	/**
	 * 
	 * @Title: updateUserDepositPassword 
	 * @Description: 修改用户提现密码(乘客端)
	 * @param userId 用户Id
	 * @param newPassword 新密码
	 * @author YHQ 
	 * @since V2.6.3
	 * @return Boolean true:成功   false:失败
	 * 
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public Boolean updateUserDepositPassword(String userId, String newPassword) {
		
		try {
			return sqlBaseDao.updateSqLRow(DepositPasswordSQL.UPDATE_USER_DEPOSIT_PASSWORD, newPassword,userId);
		} catch (Exception e) {
			log.error("修改用户提现密码时出现异常   类： " + this.getClass() + " updateUserDepositPassword()", e);
		}
		
		return false;
	}

	/**
	 * 
	 * @Title: getUserLogin 
	 * @Description: 根据用户Id获取用户登录信息
	 * @param userId 用户Id
	 * @author YHQ 
	 * @since V2.6.3
	 * @return UserLogin    返回类型
	 * 
	 */
	@Override
	@Transactional(readOnly = true)
	public UserLogin getUserLogin(String userId) {
		
		try {
			return criteriaBaseDao.getById(userId, UserLogin.class);
		} catch (Exception e) {
			log.error("根据用户Id获取用户登录信息时出现异常   类：" + this.getClass() + " getUserLogin()", e);
		}
		
		return null;
	}

}
